package jea.machine.gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JWindow;

class Splash extends JWindow 
{
	private static final long serialVersionUID = 1L;
	private int duration;
	private JLabel labelInfo;

	  public Splash(int d) 
	  {
	    duration = d;

	    JPanel panelSplash = (JPanel) getContentPane();
	    panelSplash.setBackground(Color.white);
	    int width = 450;
	    int height = 115;
	    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
	    int x = (screen.width - width) / 2;
	    int y = (screen.height - height) / 2;
	    setBounds(x, y, width, height);
	   
	    labelInfo = new JLabel("Loading...");
	    	    
	    panelSplash.add(labelInfo, BorderLayout.CENTER);
	    panelSplash.setBorder(BorderFactory.createLineBorder(Color.BLACK,1));
	    panelSplash.setBackground(Color.LIGHT_GRAY);
	    setAlwaysOnTop(true);
	    setVisible(true);

	    /*  
	    try 
	    {
	      Thread.sleep(duration);
	    } catch (Exception e) {
	    }
	    setVisible(false);
	    */
	  }
	  
	  public void setInfo(String info)
	  {
		 labelInfo.setText(info);
		 //this.repaint();
	  }
	    
	  public static void main(String[] args)
	  {
	    Splash splash = new Splash(10000);
	  }
}
